home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
satellit
/
pacdoc
/
elogdisp.c
< prev
next >
Wrap
Text File
|
1991-04-12
|
4KB
|
119 lines
/* SEU log display program for new format eltlog and eltlogxx files. */
/* Use for UO-14 files after 04 April 1991. */
/* Use for AO-16 and LO-19 files after March 1991. */
/* File formatted for tab stops 3, 5, 7, etc */
/* Structure contains NO slack bytes. */
/* INTEL lsb-first ordering assumed. */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#pragma pack(1) /* Just in case. */
struct MEMERR {
long time; /* time of correction */
unsigned int cluster; /* cluster of error */
int sector; /* sector w/in cluster */
int byte; /* byte w/in sector */
unsigned long fnumber; /* File in which error was */
int severity; /* 0 none, 1 corrected, */
/* 2 very bad. */
/* 3 seu in program RAM */
char pattern; /* pattern for type 1 */
int function; /* reason for check */
};
/* For MEMERR.function */
#define FUNC_WASH 1
#define FUNC_READ 2
/*------------------------------------------------------------------------
Funct : elogdisp
Date :
Action : Displays the error log from the PCE.
ARGS :
RETURNS :
GLOBALS :
------------------------------------------------------------------------*/
main(int argc, char * argv[]){
struct MEMERR seu;
FILE *fp;
char s1[30];
if (argc < 2) {
printf("Display eltlog file with Format Ver. 2.\n");
printf("usage: elogdisp <filename>\n");
exit(-1);
}
if ( (fp=fopen(argv[1], "rb")) == NULL) {
printf("File <%s> does not exist.\n", argv[1]);
exit(-2);
}
printf("SEU LOG:\n");
printf(" Time Cluster Sector Byte Patrn Type File Function\n");
printf("------------------- ------- ------ ---- ----- ---- ------- --------\n");
while (!feof(fp)){
if (fread(&seu, sizeof(struct MEMERR), 1, fp)) {
/* Time, cluster and sector always valid */
sprintf(s1, asctime(gmtime(&seu.time)));
s1[strlen(s1)-1] = '\0';
printf("%20.20s ", s1);
printf("0x%04x ", seu.cluster);
printf("0x%04x ", seu.sector);
/* Byte only valid on correctable errors */
if (seu.severity == 1){
printf("0x%02x ", seu.byte);
printf("0x%02x ", seu.pattern & 0xff);
}
else{
printf("----- ");
printf("----- ");
}
switch (seu.severity) {
case 1:
printf("Fixed ");
break;
case 2:
printf("SEVERE ");
break;
}
/* During WASH cycles, fnumber has 4 meanings */
if (seu.function == FUNC_WASH){
if (seu.fnumber == 0l)
printf("Directry ");
else if (seu.fnumber == -1l)
printf("in FAT ");
else if (seu.fnumber == -2l)
printf("in FREE ");
else
printf("%08lx ", seu.fnumber);
}
/* During READ cycles, fnumber has no meaning */
else if (seu.function == FUNC_READ){
if (seu.fnumber < 1l)
printf("error ");
else
printf("unknown ");
}
else
printf( "bad func ");
/* Tell which function it was */
if (seu.function == FUNC_WASH)
printf("Wash\n");
else if (seu.function == FUNC_READ)
printf("Read\n");
else printf("????\n");
}
}
}